<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        let input = `10
1 1 1 1 1 9 8 3 7 10`
        let spl = input.split('\n')

        let sum = 0
        let [n, arr] = [parseInt(spl[0]), spl[1].trim().split(' ').map(v => {
            let t = parseInt(v.trim())
            sum += t
            return t
        })]

        if (sum % 2) {
            console.log('no');
        } else {
            let count = 0
            sum = sum / 2
            
            let dp = new Array(sum + 1).fill(Infinity)

            dp[0] = 0

            for (let weight of arr) {
                for (let j = sum; j >= weight; j--) {
                    if (dp[j - weight] !== Infinity) {
                        dp[j] = Math.min(dp[j], dp[j - weight] + 1)
                    }
                }

            }
            if(dp[sum]===Infinity){
                console.log('no');
                
            }else{
                console.log(dp[sum]);                
            }

            console.log(n, sum, arr);
        }











        // function canDivideStones(stones) {
        //     const totalWeight = stones.reduce((acc, val) => acc + val, 0);
        //     if (totalWeight % 2 !== 0) return -1;

        //     const target = totalWeight / 2;
        //     const dp = Array(target + 1).fill(false);
        //     dp[0]= true;

        //     for (let i = 0; i < stones.length; i++) {
        //         for (let j = target; j >= stones[i]; j--) {
        //             dp[j] = dp[j] || dp[j - stones[i]];
        //         }
        //     }

        //     if (!dp[target]) return -1;

        //     // 回溯查找具体的组合
        //     let combination = [];
        //     let currentTarget = target;
        //     for (let i = stones.length - 1; i >= 0 && currentTarget > 0; i--) {
        //         if (dp[currentTarget - stones[i]]) {
        //             combination.push(stones[i]);
        //             currentTarget -= stones[i];
        //         }
        //     }

        //     return combination.length;
        // }

        // // 测试用例
        // console.log(canDivideStones([1, 1, 2, 2]));  // 输出 2
        // console.log(canDivideStones([1, 1, 1, 1, 1, 9, 8, 3, 7, 10]));  // 输出 -1


    </script>
</body>

</html>